﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using KPIS.GERP.Models.Class;

namespace KPIS.GERP.Models.ICM
{
    [DataContract, Table("IcmMovement")]
    public class Movement
    {

        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [DataMember, Display(Name = "MovementId", ResourceType = typeof(Resources.MovementResource))]
        public int MovementId { get; set; }

        [CustomRequired]
        [DataMember, Display(Name = "Title", ResourceType = typeof(Resources.MovementResource))]
        public string Title { get; set; }

        [ForeignKey("MasResourceType")]
        [DataMember, Display(Name = "ResTypeId", ResourceType = typeof(Resources.MovementResource))]
        public int ResTypeId { get; set; }

        [DataMember, Display(Name = "RefNo", ResourceType = typeof(Resources.MovementResource))]
        public string RefNo { get; set; }

        [CustomRequired]
        [DataMember, Display(Name = "MoveMethod", ResourceType = typeof(Resources.MovementResource))]
        public int MoveMethod { get; set; }

        [ForeignKey("SourceWarehouse")]
        [DataMember, Display(Name = "SourceWarehouseId", ResourceType = typeof(Resources.MovementResource))]
        public int? SourceWarehouseId { get; set; }

        [ForeignKey("SourceJobSite")]
        [DataMember, Display(Name = "SourceJobSiteId", ResourceType = typeof(Resources.MovementResource))]
        public int? SourceJobSiteId { get; set; }

        [ForeignKey("SourceEmployee")]
        [DataMember]
        public int? SourceEmpId { get; set; }

        [ForeignKey("DestinationWarehouse")]
        [DataMember, Display(Name = "DestinationWarehouseId", ResourceType = typeof(Resources.MovementResource))]
        public int? DestinationWarehouseId { get; set; }

        [ForeignKey("DestinationJobSite")]
        [DataMember]
        public int? DestinationJobSiteId { get; set; }

        [ForeignKey("DestinationEmployee")]
        [DataMember]
        public int? DestinationEmpId { get; set; }

        [DataMember, Display(Name = "Remark", ResourceType = typeof(Resources.MovementResource))]
        public string Remark { get; set; }

        [StringLength(2)]
        [DataMember, Display(Name = "RecordStatus", ResourceType = typeof(SYS.Resources.RecordStatusResource))]
        public string RecordStatus { get; set; }

        [DataMember, Display(Name = "CreatedBy", ResourceType = typeof(SYS.Resources.RecordStatusResource))]
        public int? CreatedBy { get; set; }

        [DataMember, Display(Name = "CreatedWhen", ResourceType = typeof(SYS.Resources.RecordStatusResource))]
        public DateTime? CreatedWhen { get; set; }

        [DataMember, Display(Name = "UpdatedBy", ResourceType = typeof(SYS.Resources.RecordStatusResource))]
        public Nullable<int> UpdatedBy { get; set; }

        [DataMember, Display(Name = "UpdatedWhen", ResourceType = typeof(SYS.Resources.RecordStatusResource))]
        public Nullable<DateTime> UpdatedWhen { get; set; }
        
        [DataMember]
        public virtual MasResourceType MasResourceType { get; set; }

        [DataMember]
        public virtual Warehouse SourceWarehouse { get; set; }

        [DataMember]
        public virtual Warehouse DestinationWarehouse { get; set; }

        [DataMember]
        public virtual HRM.JobSite SourceJobSite { get; set; }

        [DataMember]
        public virtual HRM.JobSite DestinationJobSite { get; set; }

        [DataMember]
        public virtual HRM.Employee SourceEmployee { get; set; }

        [DataMember]
        public virtual HRM.Employee DestinationEmployee { get; set; }
        //[DataMember, NotMapped]
        //public string MoveMethodName
        //{
        //    get
        //    {
        //        if (this.MoveMethod == '0')
        //        {
        //            return "จากคลังไปคลัง";
        //        }
        //        else if (this.MoveMethod == '1')
        //        {
        //            return "จากหน่วยงานไปคลัง";
        //        }
        //        else
        //        {
        //            return "ไม่ได้เลือกวิธีโอนย้าย";
        //        }
        //    }
        //}

    }
}
